package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mapper.SettingsMapper;
import com.tanhua.model.domain.Settings;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;


@DubboService
public class SettingsApiImpl implements SettingsApi{
    @Autowired
     private SettingsMapper settingsMapper;

    @Override
    public Settings findByUserId(Long userId) {
        QueryWrapper<Settings> qw=new QueryWrapper<>();
        qw.eq("user_id",userId);
        return settingsMapper.selectOne(qw);
      /*  LambdaQueryWrapper<Settings> queryWrapper=new LambdaQueryWrapper<>();
        queryWrapper.eq(Settings::getUserId,userId);
        return settingsMapper.selectOne(queryWrapper);*/
    }

    @Override
    public void update(Settings settings) {
    settingsMapper.updateById(settings);
    }

    @Override
    public void save(Settings settings) {
        settingsMapper.insert(settings);
    }
}
